#pragma once
#include<string>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>

#define Die(code) \
    do              \
    {               \
        exit(code);    \
    } while (0)


#define CONV(v) (const struct sockaddr*)(v)

enum
{
    USAGE_ERR=1,
    SOCKET_ERR,
    BIND_ERR
};
           
bool SpilyString(const std::string line,std::string*key,std::string*value,const std::string& sep)
{
    auto pos=line.find(sep);
    if(pos==std::string::npos)return false;//找不到分割符
    *key=line.substr(0,pos);//左闭右开
    *value=line.substr(pos+sep.size(),line.size());//不写第二个参数默认是到string结尾
    if(key->empty()||value->empty())return false;//判断如果不存在就返回false
    return true;
}
